package com.knight.jdk8.comparator;

import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * @Description:
 * @author: knight
 * @Date: 2019-05-19 14:53
 */
public class MyComparator {
    public static void main(String[] args) {
        List<String> list = Arrays.asList("nihao","hello","welcome");
/*        Collections.sort(list,((item1,item2 )-> item2.length()-item1.length()));
        System.out.println(list);
        System.out.println("----------------------------");
        Collections.sort(list, Comparator.comparingInt(String::length).reversed());
        System.out.println(list);*/

        System.out.println("------------多个比较器组合------------");
        // 先按照长度排序如果长度相同，则再按照ASC码排序
        Collections.sort(list,Comparator.comparingInt(String::length).thenComparing(String.CASE_INSENSITIVE_ORDER));
        System.out.println(list);


    }
}
